<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>企业员工管理-修改密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="static/css/font.css">
    <link rel="stylesheet" href="static/css/xadmin.css">
    <script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="static/lib/layui/layui.js"></script>
    <script type="text/javascript" src="static/js/xadmin.js"></script>
   
</head>

<body>
<div class="x-body layui-anim layui-anim-up">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="old_pass" class="layui-form-label">
                <span class="x-red">*</span>原密码：
            </label>
            <div class="layui-input-inline">
                <input type="password" id="old_pass" name="pass" required="" lay-verify=""
                       autocomplete="off" class="layui-input" placeholder="请填写原密码" style="width: 30rem;">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">
                <span class="x-red">*</span>新密码：
            </label>
            <div class="layui-input-inline">
                <input type="password" id="L_pass" name="pass" required="" lay-verify="pass"
                       autocomplete="off" class="layui-input" placeholder="密码不得少于 6 位，且必须包含数字、字母和符号" style="width: 30rem;">
            </div>
           
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
                <span class="x-red">*</span>确认密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="L_repass" name="repass" required="" lay-verify="repass"
                       autocomplete="off" class="layui-input" placeholder="密码不得少于 6 位，且必须包含数字、字母和符号" style="width: 30rem;">
            </div>
          
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button class="layui-btn" lay-filter="updatePassword" lay-submit="" style="width: 100%">
                修改密码
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        //自定义验证规则
        form.verify({
            pass: [/^(?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]]).{6,16}$/, '密码不得少于 6 位，且必须包含数字、字母和符号！']
            , repass: function (value) {
                if ($('#L_pass').val() != $('#L_repass').val()) {
                    return '两次密码不一致';
                }
            }
        });

        //监听提交
        form.on('submit(updatePassword)', function (data) {
            $.ajax({
                type: 'post',
                url: 'changePassword.do',
                data: {
                    'oldPassword': $("#old_pass").val(),
                    'newPassword': $("#L_pass").val(),
                    'rePassword': $("#L_repass").val(),
                },
                dataType: 'json',
                success: function (result) {
                    if (result.type == "success") {
                        layer.alert(result.msg, {icon: 6}, function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                        });
                    } else {
                        $("#old_pass").val("").focus();
                        $("#L_pass").val("");
                        $("#L_repass").val("");
                        layer.alert(result.msg, {icon: 5});
                    }
                }
            });
            return false;
        });
    });
</script>

</body>

</html>